package it.uni.bo.monitoring.sla.chain.latency;

import static it.uni.bo.monitoring.service.StaticFields.INB;
import static it.uni.bo.monitoring.service.StaticFields.OUTB;

import it.uni.bo.monitoring.protocol.unmarshaller.EventInfo;
import it.uni.bo.monitoring.sla.context.ComponentManager;
import it.uni.bo.monitoring.sla.context.MonitoringComponent;
import it.uni.bo.monitoring.sla.context.MonitoringContext;

import java.util.List;


public class MonitoringLatency extends MonitoringComponent{

	public MonitoringLatency() {
	}

	@Override
	public void processEvent(EventInfo ei, MonitoringContext mc) {
		if(	ei.getDirection()==(Character.forDigit(INB & 0xFF, 2))	||
			ei.getDirection()==(Character.forDigit(OUTB & 0xFF, 2))	 ){

			List<ComponentManager> lList=mc.getLatencyList();
			if ( lList != null ){
				for(int i=0;i<lList.size();i++)
					lList.get(i).makeTrans(ei);
			}
		}
		if(next!=null)
			next.processEvent(ei, mc);
	}

}
